/**
 * Copyright &copy; 2013-2015 山东易科德软件有限公司 All rights reserved.
 */
package cn.net.ecode.modules.sys.entity;

import javax.validation.constraints.NotNull;
import javax.xml.bind.annotation.XmlAttribute;

import org.hibernate.validator.constraints.Length;

import cn.net.ecode.common.persistence.TreeEntity;
import cn.net.ecode.common.persistence.annotation.Id;
import cn.net.ecode.common.utils.StringUtils;

/**
 * 字典Entity
 * @author ThinkGem
 * @version 2014-8-19
 */
public class Dict extends TreeEntity<Dict> {

	private static final long serialVersionUID = 1L;
	private String dictCode; // 字典编码
	private String name;		// 字典名
	private String value;		// 字典值
	private String type;		// 字典类型
	private String description;		// 描述
	private String isSys;		// 系统内置（1是 0否）
	private String cssStyle;		// css样式（如：color:red)
	private String cssClass;		// css类（如：red）
	
	public Dict() {
		super();
	}

	public Dict(String id){
		super(id);
	}
	
	public Dict(String value, String name){
		this.value = value;
		this.name = name;
	}
	
	public Dict getParent() {
		return parent;
	}

	public void setParent(Dict parent) {
		this.parent = parent;
	}

	@Id
	public String getDictCode() {
		return dictCode;
	}

	public void setDictCode(String dictCode) {
		this.dictCode = dictCode;
	}
	
	@NotNull
	public Integer getSorts() {
		return sorts;
	}

	public void setSorts(Integer sorts) {
		this.sorts = sorts;
	}
	
	/**
	 * 字典名称
	 * @return
	 */
	@XmlAttribute
	@Length(min=0, max=100, message="字典名长度不能超过 100 个字符")
	public String getName() {
		return name;
	}

	public void setName(String name) {
		this.name = name;
	}
	
	/**
	 * 字典标签，同 getName()
	 */
	public String getLabel() {
		return name;
	}

	/**
	 * 字典值
	 * @return
	 */
	@XmlAttribute
	@Length(min=0, max=100, message="字典值长度不能超过 100 个字符")
	public String getValue() {
		return value;
	}

	public void setValue(String value) {
		this.value = value;
	}

	/**
	 * 字典类型
	 * @return
	 */
	@XmlAttribute
	@Length(min=0, max=100, message="字典类型长度不能超过 100 个字符")
	public String getType() {
		return type;
	}

	public void setType(String type) {
		this.type = type;
	}
	
	@XmlAttribute
	@Length(min=0, max=100, message="描述长度不能超过 100 个字符")
	public String getDescription() {
		return description;
	}

	public void setDescription(String description) {
		this.description = description;
	}
	
	@Length(min=0, max=1, message="系统内置（1是 0否）长度不能超过 1 个字符")
	public String getIsSys() {
		return isSys;
	}

	public void setIsSys(String isSys) {
		this.isSys = isSys;
	}
	
	@Length(min=0, max=500, message="css样式（如：color:red)长度不能超过 500 个字符")
	public String getCssStyle() {
		return cssStyle;
	}

	public void setCssStyle(String cssStyle) {
		this.cssStyle = cssStyle;
	}
	
	@Length(min=0, max=500, message="css类（如：red）长度不能超过 500 个字符")
	public String getCssClass() {
		return cssClass;
	}

	public void setCssClass(String cssClass) {
		this.cssClass = cssClass;
	}
	
	public String getDescriptionAbbr() {
		return StringUtils.abbr(description, 25) ;
	}
	
	@Override
	public String toString() {
		return value;
	}
}